/*
 * @Author: WangShuai 1830773767@qq.com
 * @Date: 2025-06-23 23:38:12
 * @LastEditors: WangShuai 1830773767@qq.com
 * @LastEditTime: 2025-06-29 14:56:20
 * @FilePath: \shangyitong\src\api\user\index.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import service from "@/utils/request";
import type {UserLoginResponse,LoginData,WXLoginResponseData,
    SubmitOrder,OrderResponseData,
    QrCode,PayResult,UserInfoResponseData,
    CertificationTypeResoponse,
    UserParams,OrderInfoResponseData,UserInfoDataResponseData,
    OrderStatusResponseData,CityDataResponse,
    Partient
} from'./type'
enum API {
    //用户登录接口
    USERLOGIN_URL= "/user/login",
    //用户退出登录接口
    USERLIGONOUT_URL = "/user/logout",
    //获取微信扫码登录相关参数
    WXLIGON_URL="/user/weixin/getLoginParam",
    //提交订单接口
    SUBMITORDER_URL='/order/orderInfo/auth/submitOrder/',//{hoscode}/{scheduleld}/{patientId}
    //获取订单详情数据
    GETORDERINFO_URL = "/order/orderInfo/auth/getOrderinfo/",//{id}
    //取消预约订单的接口
    ORDERCANCEL_URL = "/order/orderInfo/auth/cancelOrder/",
    //支付订单生成二维码接口
    QRCODE_URL = '/order/weixin/createNative/',//{orderId}
    //查询微信支付状态
    PAYRESULT_URL = '/order/weixin/queryPayStatus/',//{orderld}
    //获取会员信息接口
    GETUSERINFO_URL="/user/auth/getUserInfo",
    //获取证件类型接口(身份证或户口本)
    CERTIFICATIONTYPE_URL ='/cmn/dict/findByDictCode/',//{dictCode}
    //会员认证接口
    USERCATIFICATION_URL = "/user/auth/userAuah",
    //获取用户订单号接口
    USERORDERINFO_URL = "/order/orderInfo/auth/",//{page}/{limit}
    //获取所有就诊人的接口
     GETUSERALL_URL= '/user/patient/auth/findAll',
     //获取所有订单状态
     GETORDERDSTATUS_URL = '/order/orderInfo/auth/getStatusList',
     //获取有省份数据 // 86
     CITY_URL='/cmn/dict/findByParentId/',
     //新增就诊人接口
     ADDPATIENT_URL = '/user/patient/auth/save',
     //更新就诊人接口
     UPDATEPATIENT_URL = '/user/patient/auth/update',
     //删除就诊人信息接口
     REMOVE_URL = '/user/patient/auth/remove/',//{id}
}
//用户登录方法
export const reqUserLogin = (data:LoginData)=>service.post<any,UserLoginResponse>(API.USERLOGIN_URL,data)
//用户退出登录
export const reqUserLogout = ()=>service.get<any,any>(API.USERLIGONOUT_URL)
//获取微信扫码登录生成二维码需要的参数接口
export const reqWxLogin = (wxRedirectUri:string)=>service.get<any,WXLoginResponseData>(API.WXLIGON_URL+`?wxRedirectUri=${wxRedirectUri}`)
//提交订单
export const reqSubmitOrder = (hoscode:string,scheduleld:string,patientId:number)=>service.post<any,SubmitOrder>(API.SUBMITORDER_URL+`${hoscode}/${scheduleld}/${patientId}`)
//获取订单详情的方法
export const reqGetOrderInfo = (id:string)=>service.get<any,OrderResponseData>(API.GETORDERINFO_URL+`${id}`)
//预约订单取消方法
export const reqOrderCancel = (id:string)=>service.get<any,any>(API.ORDERCANCEL_URL+`${id}`)
//支付订单生成二维码接口
export const reqQrcode = (orderId:string)=>service.get<any,QrCode>(API.QRCODE_URL+`${orderId}`)
//查询为微信用户支付状态
export const reqQueryStatus = (orderId:string)=>service.get<any,PayResult>(API.PAYRESULT_URL+`${orderId}`)
//获取会员信息
export const reqUserInfo = ()=>service.get<any,UserInfoResponseData>(API.GETUSERINFO_URL)
//获取证件类型接口方法
export const reqCertificationType = (CertificatesType="CertificatesType")=>service.get<any,CertificationTypeResoponse>(API.CERTIFICATIONTYPE_URL+`${CertificatesType}`)
//用户认证接口方法
export const reqUserCatification = (data:UserParams)=>service.post<any,any>(API.USERCATIFICATION_URL,data)
//获取用户订单接口方法
export const reqOrderInfo = (page:number,limit:number,patientId:string,orderStatus:string)=>service.get<any,OrderInfoResponseData>(API.USERORDERINFO_URL+`${page}/${limit}?patientId=${patientId}&orderStatus=${orderStatus}`)
//获取所有就诊人方法
export const reqUserAll = ()=>service.get<any,UserInfoDataResponseData>(API.GETUSERALL_URL)
//获取所有订单状态的方法
export const reqOrderStatus = ()=>service.get<any,OrderStatusResponseData>(API.GETORDERDSTATUS_URL)
//获取所有省市县的数据
export const reqCityData = (parentId:string)=>service.get<any,CityDataResponse>(API.CITY_URL+`${parentId}`)
//新增或更新就诊人接口方法
export const reqAddORUpdatePatient = (data:Partient)=>{
    //更新就诊人信息
    if(data.id){
       return  service.put<any,any>(API.UPDATEPATIENT_URL,data)
    }else{
       //新添加就诊人
      return  service.post<any,any>(API.ADDPATIENT_URL,data)
    }
}
//删除就诊人信息接口
export const reqRemove = (id:number)=>service.delete<any,any>(API.REMOVE_URL+`${id}`)